package ryarithsGame;

import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.scene.Node;

public class Level4 extends Node 
{

	private PuzzleNode[] puzzle;
	private Goal goal;
	private static final long serialVersionUID = 1L;

	public Level4()
	{
		super("Level4");
		loadPuzzle();
	}
	
	private void loadPuzzle()
	{
		goal = new Goal("goal", new Vector3f(600,15,25));
		puzzle = new PuzzleNode[10];
		puzzle[0] = new PuzzleNode("switch0", 0, new Vector3f(319.5f,10,312.5f),new Vector3f(-100,10,-100));
		puzzle[1] = new PuzzleNode("switch1", 0, new Vector3f(305.5f,10,312.5f),new Vector3f(-100,10,-100));
		puzzle[2] = new PuzzleNode("switch2", 0, new Vector3f(312.5f,10,319.5f),new Vector3f(-100,10,-100));
		puzzle[3] = new PuzzleNode("switch3", 0, new Vector3f(312.5f,10,305.5f),new Vector3f(-100,10,-100));
		
		puzzle[4] = new PuzzleNode("switch4", 0, new Vector3f(125,10,125),new Vector3f(600,15,25));
		puzzle[5] = new PuzzleNode("switch5", 0, new Vector3f(500,10,500),new Vector3f(600,15,25));
		puzzle[6] = new PuzzleNode("switch6", 0, new Vector3f(125,10,500),new Vector3f(600,15,25));
		
		puzzle[7] = new PuzzleNode("switch7", 1, new Vector3f(610,10,25),new Vector3f(125,10,125));
		puzzle[8] = new PuzzleNode("switch8", 1, new Vector3f(590,10,25),new Vector3f(500,10,500));
		puzzle[9] = new PuzzleNode("switch9", 1, new Vector3f(600,10,35),new Vector3f(125,10,500));
		this.attachChild(goal);
		this.attachChild(puzzle[0]);
		this.attachChild(puzzle[1]);
		this.attachChild(puzzle[2]);
		this.attachChild(puzzle[3]);
		this.attachChild(puzzle[4]);
		this.attachChild(puzzle[5]);
		this.attachChild(puzzle[6]);
		this.attachChild(puzzle[7]);
		this.attachChild(puzzle[8]);
		this.attachChild(puzzle[9]);
		
	}
	
	public void updateLevel(float tpf)
	{
		for(int i = 0; i < puzzle.length; i++)
		{
			puzzle[i].updatePuzzleNode(tpf);
		}
		goal.updateGoalNode();	
	}
	
	public void checkSwitchCollisions(Vector2f camPos)
	{
		goal.checkSwitchCollisions(camPos);
	}
	
	public boolean getGoalSwitch()
	{
		return goal.getIsSwitched();
	}
	
	public PuzzleNode getPuzzleNode(int i)
	{
		return puzzle[i];
	}
	
	public int puzzleSize()
	{
		return puzzle.length;
	}
	
	public void attachNode(int i)
	{
		this.attachChild(puzzle[i]);
	}
	
	
}
